package org.yylnb.openplatform.search.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Component;
import org.yylnb.openplatform.search.service.SearchService;

/**
 * @author RainLin
 * @date 2020/8/1 - 11:15
 */
@Component
public class LoggerMQlistener {
    private final SearchService searchService;

    public LoggerMQlistener(SearchService searchService) {
        this.searchService = searchService;
    }

    @StreamListener("openplatformlog")
    public void onMessage(String loggerJosn) {
        System.err.println("收到日志数据:" + loggerJosn);
        try {
            searchService.add(loggerJosn);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

